local fanSkill = fk.CreateSkill {
  name = "#lvshi__fan_skill",
  attached_equip = "lvshi__fan",
}

local U = require "packages/utility/utility"

fanSkill:addEffect(fk.AfterCardUseDeclared, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(fanSkill.name) and (data.card.name == "slash" or data.card.name == "lvshi__slash")
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#fans-invoke")
  end,
  on_use = function(self, event, target, player, data)
    player.room:broadcastPlaySound("./packages/maneuvering/audio/card/fan")
    player.room:setEmotion(player, "./packages/maneuvering/image/anim/fan")
    data:changeCard("fire__slash", data.card.suit, data.card.number, fanSkill.name)
  end,
})

fanSkill:addEffect(fk.DamageCaused, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(fanSkill.name) and data.card and string.find(data.card.name, "fire__slash")
    and U.isPureCard(data.card)
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player.room:broadcastPlaySound("./packages/maneuvering/audio/card/fan")
    player.room:setEmotion(player, "./packages/maneuvering/image/anim/fan")
    data:changeDamage(1)
  end,
})

return fanSkill